package cn.yitun.chat.yitunserverrunsingleboot.chat.properties;

import cn.yitun.chat.yitunserverrunsingleboot.chat.factory.YamlPropertyLoaderFactory;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * 数据库配置类
 * @author chenyitun
 * @date 2020-06-07
 */
@Data
@NoArgsConstructor
@Configuration
@PropertySource(value = {"classpath:config/path.yml"}, factory = YamlPropertyLoaderFactory.class, ignoreResourceNotFound = true)
public class PathProperties {
    /**
     * 这个地址是此项目运行的服务器地址，就是其他电脑可以访问此服务的IP地址
     * 当为空的时候，系统自动获取此电脑IP，可能会不对，所以建议配置
     */
    @Value("${server.address}")
    private String serverAddress;
    //tcp端口
    @Value("${chat.server.tcp.address}")
    private String tcpAddress;
    @Value("${chat.server.tcp.port}")
    private Integer tcpPort;
    //udp端口
    @Value("${chat.server.udp.address}")
    private String udpAddress;
    @Value("${chat.server.udp.port}")
    private Integer udpPort;
    //websocket请求路径
    @Value("${chat.server.websocket.address}")
    private String websocketAddress;
    @Value("${chat.server.websocket.port}")
    private Integer websocketPort;
    @Value("${chat.server.websocket.suffix}")
    private String websocketSuffix;
    //websocket请求路径
    @Value("${chat.server.http.address}")
    private String httpAddress;
    @Value("${chat.server.http.port}")
    private Integer httpPort;
    //文件地址
    @Value("${chat.server.file.http.address}")
    private String fileHttpAddress;
    @Value("${chat.server.file.http.port}")
    private Integer fileHttpPort;
    //远程调用端口
    @Value("${chat.server.remote.tcp.address}")
    private String remoteTcpAddress;
    @Value("${chat.server.remote.tcp.port}")
    private Integer remoteTcpPort;
    //api调用端口
    @Value("${chat.server.api.http.address}")
    private String apiHttpAddress;
    @Value("${chat.server.api.http.port}")
    private Integer apiHttpPort;


    @Override
    public String toString() {
        return "PathProperties{" +
                "serverAddress='" + serverAddress + '\'' +
                ", tcpAddress=" + tcpAddress +
                ", tcpPort=" + tcpPort +
                ", udpAddress=" + udpAddress +
                ", udpPort=" + udpPort +
                ", websocketAddress='" + websocketAddress + '\'' +
                ", websocketPort='" + websocketPort + '\'' +
                ", websocketSuffix='" + websocketSuffix + '\'' +
                ", httpAddress='" + httpAddress + '\'' +
                ", httpPort='" + httpPort + '\'' +
                ", fileHttpAddress='" + fileHttpAddress + '\'' +
                ", fileHttpPort='" + fileHttpPort + '\'' +
                ", remoteTcpAddress=" + remoteTcpAddress +
                ", remoteTcpPort=" + remoteTcpPort +
                '}';
    }
}